﻿@model Home.WebUI.Areas.Admin.Models.QuoteViewModel.CreateViewModel
@{
    ViewBag.Title = "CMS管理系统";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

@section head{
   <script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@*http://archive.cnblogs.com/a/2110848/*@
<script type="text/javascript">
    $(function () {
        $('#ParentId').change(function () {
    $.ajax({
    type: "POST",
    url:"@Url.Action("ddlZParent")",
    dataType: "json",
    data: { ParentId: $("#ParentId").val()},
    error:function(err){
        alert("网络连接失败，请检查网络状态，或稍后访问，谢谢！");
    },
    success:function(data){
        $("#ChildId").empty();//删除子节点
        $.each(data,function(i,item){
        $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#ChildId"));//创建元素并追加到zParentId中
        })
        if (data.length>0) {
    $("#ChildId").show();
    $.ajax({
    type: "POST",
    url:"@Url.Action("ddlBrand")",
    dataType: "json",
    data: { ParentId: $("#ChildId").val()},
    error:function(err){
        alert("网络连接失败，请检查网络状态，或稍后访问，谢谢！");
    },
    success:function(data){
    $("#BrandId").empty();//删除子节点
        $.each(data,function(i,item){
        $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#BrandId"));//创建元素并追加到zParentId中
        })
    }

    })


    }
    else {
        $("#ChildId").hide();


        $.ajax({
    type: "POST",
    url:"@Url.Action("ddlBrand")",
    dataType: "json",
    data: { ParentId: $("#ParentId").val()},
    error:function(err){
        alert("网络连接失败，请检查网络状态，或稍后访问，谢谢！");
    },
    success:function(data){
    $("#BrandId").empty();//删除子节点
        $.each(data,function(i,item){
        $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#BrandId"));//创建元素并追加到zParentId中
        })
    }

    })


    }
        //$("#zParentId").show();
        }
        })
    })


    $("#ChildId").change(function(){
    $.ajax({
    type: "POST",
    url:"@Url.Action("ddlBrand")",
    dataType: "json",
    data: { ParentId: $("#ChildId").val()},
    error:function(err){
        alert("网络连接失败，请检查网络状态，或稍后访问，谢谢！");
    },
    success:function(data){
     $("#BrandId").empty();//删除子节点
     $.each(data,function(i,item){
        $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#BrandId"));//创建元素并追加到zParentId中
        })
    }
    });
});
   });   
</script>
}
<div id="bdw" class="bdw">
<div id="bd" class="cf">
<div id="partner">
	@{Html.RenderPartial("_Manager");}
	<div id="content" class="clear mainwide">
        <div class="clear box">
            <div class="box-top"></div>
            <div class="box-content">
                <div class="head"><h2>新建@(ViewBag.ColumnTitle)</h2>
                </div>
                <div class="sect">
                    @using (Html.BeginForm("Create", "Quote", FormMethod.Post, new { enctype = "multipart/form-data" }))
                    {
                   @* @Html.ValidationSummary(true)*@
						@*<div class="wholetip clear"><h3>1、登录信息</h3></div>*@
                        <div class="field" >
                            <label>分类</label>
                            @Html.DropDownListFor(model => model.ParentId, ViewBag.Category as SelectList, new { @class = "f-input", style = "width:200px" })
                           
                             @Html.DropDownListFor(model => model.ChildId, ViewBag.ChildList as SelectList, new { @class = "f-input", style = (ViewBag.ChildList as SelectList).Count() > 0 ? "width:200px;" : "width:200px;display:none" })
                            <div class="clear"></div>
                        </div>
                        <div class="field">
                        <label>品牌</label>
                        @Html.DropDownListFor(model => model.BrandId, ViewBag.BrandList as SelectList, new { @class = "f-input", style = "width:200px" })
                            @Html.ValidationMessageFor(model => model.BrandId)
                        <div class="clear"></div>
                        </div>
                        <div class="field">
                            <label>报价</label>
                            <input id="QuoteDetails" name="QuoteDetails" type="file" data-val="true"  data-val-required="报价不能为空"  class = "f-input" />
                          @* @Html.TextBoxFor(model => model.Name, new { @class = "f-input" })*@
                            <div class="clear"></div>
                            <span class="field-validation-valid" data-valmsg-for="QuoteDetails" data-valmsg-replace="true"></span>
                        </div>
                        
                        <div class="act">
                            <input type="submit" value="新建" name="commit" id="partner-submit" class="formbutton"/>
                        </div>
                    }
                </div>
            </div>
            <div class="box-bottom"></div>
        </div>
	</div>

<div id="sidebar">
</div>

</div>
</div> <!-- bd end -->
</div> <!-- bdw end -->